﻿<ig:XamDialogWindow 
    x:Class="Sidvall.UI.Wpf.Dialogs.XamFileDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:b="clr-namespace:Sidvall.UI.Wpf.Controls;assembly=Sidvall.UI.Wpf"
    xmlns:Converters="clr-namespace:Sidvall.UI.Wpf.Converters;assembly=Sidvall.UI.Wpf" 
    xmlns:Controls="clr-namespace:Sidvall.UI.Wpf.Controls;assembly=Sidvall.UI.Wpf" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vms="clr-namespace:Sidvall.UI.Wpf.ViewModels"
    xmlns:ig="http://schemas.infragistics.com/xaml" 
    mc:Ignorable="d" 
    FocusManager.IsFocusScope="True"
    Controls:AccessKeyScoper.IsAccessKeyScope="True"
    Height="400" Width="600" Header="{Binding Title}" Panel.ZIndex="15" IsResizable="True" IsModal="True" HeaderIconVisibility="Collapsed" CloseButtonVisibility="Visible" StartupPosition="Center" WindowStateChanged="XamDialogWindow_WindowStateChanged">

    <ig:XamDialogWindow.Resources>
        <Converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <b:BusyIndicatorControl x:Key="BusyIndicatorControl" />
    </ig:XamDialogWindow.Resources>

    <Grid d:DataContext="{d:DesignInstance IsDesignTimeCreatable=True, Type={x:Type vms:FileDialogViewModel}}">
        <b:BusyIndicatorControl HeaderCaption="LOADING..." Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}" Panel.ZIndex="20" />
        <Grid IsEnabled="{Binding IsBusy, Converter={StaticResource InverseBooleanConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <ig:XamDataTree ItemsSource="{Binding Folders}" ActiveDataItem="{Binding ActiveFolder, Mode=TwoWay}" DisplayMemberPath="Name" 
                            IsExpandedMemberPath="IsExpanded" IsSelectedMemberPath="IsSelected"
                            NodeExpansionChanged="XamDataTree_NodeExpansionChanged" SelectedNodesCollectionChanged="XamDataTree_SelectedNodesCollectionChanged">
                <ig:XamDataTree.SelectionSettings>
                    <ig:TreeSelectionSettings NodeSelection="Single"/>
                </ig:XamDataTree.SelectionSettings>
                <ig:XamDataTree.GlobalNodeLayouts>
                    <ig:NodeLayout Key="ChildItems" DisplayMemberPath="Name" />
                </ig:XamDataTree.GlobalNodeLayouts>
            </ig:XamDataTree>
            <GridSplitter Grid.Column="1" Width="3" ResizeDirection="Columns" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
            <ig:XamGrid Grid.Column="3" ItemsSource="{Binding FolderItems}" AutoGenerateColumns="False" ActiveItem="{Binding ActiveFolderItem, Mode=TwoWay}" 
                        MouseDoubleClick="XamGrid_MouseDoubleClick">
                <ig:XamGrid.Columns>
                    <ig:TextColumn Key="Name" HeaderText="Name"  Width="*" />
                </ig:XamGrid.Columns>
                <ig:XamGrid.ClipboardSettings>
                    <ig:ClipboardSettings AllowCopy="True" />
                </ig:XamGrid.ClipboardSettings>
                <ig:XamGrid.SelectionSettings>
                    <ig:SelectionSettings RowSelection="Multiple" CellClickAction="SelectRow"/>
                </ig:XamGrid.SelectionSettings>
            </ig:XamGrid>

            <Grid Grid.Row="1" Grid.ColumnSpan="3" Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
            
                <TextBox Text="{Binding FileName}" />
                <Button Grid.Column="1" IsDefault="True" Width="80" Margin="5,0,0,0" Click="OnOpenClick">Open</Button>
                <Button Grid.Column="2" IsCancel="True" Width="80" Margin="5,0,0,0" Click="OnCancelClick">Cancel</Button>
            </Grid>
        </Grid>
    </Grid>
</ig:XamDialogWindow>
